function handlerCookies(ctx) {
  console.log(ctx.cookies);
  if (ctx.url === '/home') {
    ctx.cookies.set('cid', 'hello world', {
      domain: 'localhost',  // 写cookies所在的域名
      path: '/home', // 写cookies所在的路径
      maxAge: 10 * 60 * 1000, // cookies有效时长
      expires: new Date('2018-06-18'),  // cookies失效时间
      httpOnly: false,
      overwrite: false,
    });
  }
}

module.exports = ()=>{
  return async (ctx, next) =>{
    handlerCookies(ctx);
    next && await next();
  };
};
